package keter.service;

import java.util.List;

import keter.dao.org.RoleDao;
import keter.domain.Role;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class RoleService {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = LoggerFactory.getLogger(RoleService.class);
	
	@Autowired
	private RoleDao roleDao;
	
	public void saveOrUpdate(Role role){
		roleDao.save(role);
	}
	
	
	public List<Role> all(){
		logger.info("find all user");
		return roleDao.findAll();
	}
	
	public Role findById(Long id){
		return roleDao.findOne(id);
	}
	
	public Role findByName(String name){
	    return roleDao.findByName(name);
	}
	
	
	public void delete(Long id){
		roleDao.delete(id);
	}

}
